package com.lms.logistics_management_system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lms.logistics_management_system.controller.dto.ComboItemDto;
import com.lms.logistics_management_system.controller.dto.HistoryDiagnostic;
import com.lms.logistics_management_system.entity.Combo;
import com.lms.logistics_management_system.entity.Doctor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ComboMapper extends BaseMapper<Combo> {
    @Select("select combo_price from combo where combo_id=#{comboId}")
    double selectComboPrice(Integer comboId);

    @Select("SELECT *\n" +
            "FROM combo c\n" +
            "RIGHT JOIN combo_item ci ON c.combo_id=ci.combo_id\n" +
            "JOIN item i ON ci.item_id=i.item_id\n" +
            "ORDER BY c.combo_id,ci.item_id ;")
    List<ComboItemDto>  getAllComboItem();
    //c.combo_id,c.combo_price,c.item_id,ci.item_name,ci.item_price,ci.department_id

    @Select("SELECT * \n" +
            "FROM combo c\n" +
            "RIGHT JOIN combo_item ci ON c.combo_id=ci.combo_id\n" +
            "JOIN item i ON ci.item_id=i.item_id\n" +
            "Where c.combo_id=#{comboId}\n" +
            "ORDER BY c.combo_id,ci.item_id ;")
    List<ComboItemDto>  getComboItemById(Integer comboId);

    @Delete("delete from combo_item where combo_id=#{comboId} and item_id=#{itemId} ")
    boolean  deleteComboBy2Id(Integer comboId,Integer itemId);




}
